package xhttp

import "time"

type Option interface {
	apply(*ServerEngine)
}

// optionFunc wraps a func so it satisfies the Option interface.
type optionFunc func(*ServerEngine)

func (f optionFunc) apply(server *ServerEngine) {
	f(server)
}

func WithReadTimeout(rt time.Duration) Option {
	return optionFunc(func(server *ServerEngine) {
		server.srv.ReadTimeout = rt
	})
}

func WithWriteTimeout(wt time.Duration) Option {
	return optionFunc(func(server *ServerEngine) {
		server.srv.WriteTimeout = wt
	})
}

func WithIdleTimeout(it time.Duration) Option {
	return optionFunc(func(server *ServerEngine) {
		server.srv.IdleTimeout = it
	})
}
